# from django.contrib.auth.models import AbstractUser
# from django.db import models
#
# # Create your models here.
# class User(AbstractUser):
#     """用户模型类"""
#     mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
#
#     class Meta:
#         db_table = 'tb_users'
#         verbose_name = '用户'
#         verbose_name_plural = verbose_name

from django.db import models
from django.contrib.auth.models import AbstractUser
from utils import jwt_token, tjws
from . import constants


class User(AbstractUser):
    #自定义扩展用户类，在用户名、密码、邮箱等属性的基础上，扩展属性
    mobile=models.CharField(max_length=11,unique=True)
    email_active=models.BooleanField(default=False)

    class Meta:
        db_table='tb_users'

    # def verify_email_url(self):
    #     +  # url?token=****
    #
    # +        token = tjws.dumps({'user_id': self.id}, 60 * 60 * 24)
    # +
    # return 'http://www.meiduo.site:8080/success_verify_email.html?token=' + token


    def verify_email_url(self):
        token = tjws.dumps({'user_id':self.id},constants.VERIFY_EMAIL_EXPIRES)
        return 'http://www.meiduo.site:8080/success_verify_email.html?token=' + token